int sum(int s,int e,int r)
{
   //while(s%r!=0)s++;
   s=(s+r-1)/r*r;
  // while(e%r!=0)e--;
   e=e/r*r;
   int n=(e-s)/r+1;
   int tot=(s+e)*n/2;
   return tot;
}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int main()
{
    printf("%d\n",sum(1,1000,lcm(3,5)));
    printf("%d\n",sum(1,1000,3)+sum(1,1000,5)-sum(1,1000,lcm(3,5)));
}
